package cn.tedu.hongpei.response;

import lombok.Data;

/**
 * @author coinyang
 * @date 2023/3/21 14:38
 */

@Data
public class ResultVo {
    private Integer state;
    private String message;
    private Object data;

//    public ResultVo(Integer state, String message, Object data) {
//        this.state = state;
//        this.message = message;
//        this.data = data;
//    }

    public static ResultVo success(){
        return success(null);
    }

    public static ResultVo success(Object data){
        ResultVo resultVo = new ResultVo();
        resultVo.setData(data);
        resultVo.setState(AppCode.SUCCESS.getCode());
        return resultVo;
    }

    public static ResultVo fail(AppCode appCode,String message){
        ResultVo resultVo = new ResultVo();
        resultVo.setState(appCode.FAILED.getCode());
        resultVo.setMessage(message);
        return resultVo;
    }
}
